/**
 * home api
 */
import {
    Ajax,
    urls
} from './urls'

/**
 * 获取页面数据
 * @param {Number} startPage 
 */
export const getHomeList = async startPage => {
    let result = await Ajax.get(urls.homeListUrl.replace('startPage', startPage)).catch(e => {
        console.log(e)
        return {code: 999, message: 'local error'}
    })
    
    if (!!result) return result.data
}

/**
 * 获取城市列表数据
 */
export const getCitysList = async () => {
    let result = await Ajax.get(urls.cityListUrl).catch(e => {
        console.log(e)
        return {code: 999, message: 'local error'}
    })
    
    if (!!result) return result.data
}

export const getDetailInfo = async id => {
    // let result = await Ajax.get(`${urls.homeDetailUrl}${id}`).catch(e => {
    let result = await Ajax.get(urls.homeDetailUrl + id).catch(e => {
        console.log(e)
        return {code: 999, message: 'local error'}
    })
    
    if (!!result) return result.data
}